package com.curso.sesion10;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Employee implements Serializable {// es una interfaz 
	
	private static final long serialVersionUID = -55795979; // permite alinear o sincronizar cambios realizados despues de deserializar
	                                                       //sin presentar excepciones.
	
	public String name;
	public String address;
	public transient int SSN;
	public int number;
	
	public void mailcheck()
	{
		System.out.println("Mailign a check to"+ name+ ""+ address);
		
	}
	
	private void writeObject (ObjectOutputStream oos){
		
		try {
			oos.defaultWriteObject();
			oos.writeInt(SSN*2);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
    private void readObject (ObjectInputStream ois){
    	try {
			ois.defaultReadObject();
			SSN = ois.readInt()/2;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
		
	}

}
